<template>
  <div class="article_create">
    <!-- {{form}} -->
    <el-form :model="form">
      <el-form-item label="资讯标题">
        <el-input v-model="form.title"></el-input>
      </el-form-item>
      <el-form-item label="所属分类">
        <el-input v-model="form.categoryId"></el-input>
      </el-form-item>
      <el-form-item label="资讯内容">
        <el-input type="textarea" :rows="10" v-model="form.content"></el-input>
      </el-form-item>
      <el-form-item style="text-align:right">
        <el-button size="small" type="primary" @click="submit">发布</el-button>
      </el-form-item>
    </el-form>

    <div style="text-align:center">
      <el-button size="small" type="primary" @click="toBack">返回</el-button>
    </div>
  </div>
</template>
<script>
import {post} from '@/utils/request'
export default {
  data(){
    return {
      form:{}
    }
  },
  // 页面渲染完毕执行的函数
  mounted(){
    let article = this.$route.query;
    this.form = article;
  },
  methods:{
    submit(){
      let url = "http://39.105.231.187:8001/article/saveOrUpdate"
      post(url,this.form).then(resp => {
        // 提示
        this.$message({type:"success",message:resp.message})
        // 跳转
        this.toBack();
      })
    },
    toBack(){
      this.$router.go(-1);
    }
  }
}
</script>
<style scoped>

</style>